# 1.定义员工类Employee,属性:姓名,薪资
#
# 2.增加类属性:员工薪资信息列表
#
# 3.尝试添加对应的类方法,实例方法
#
#   类方法:对员工薪资进行排名
#
#   静态方法:每新增一个员工,添加到列表中
#
# 4.测试并执行打印结果
# 定义一个类
import operator


class Employee:
    all_cpn = []
    def __init__(self, name_1, cpn_1):
        self.name = name_1
        self.cpn = cpn_1

    def add_cpn(self):
        Employee.all_cpn.append(self.name)
        Employee.all_cpn.append(self.cpn)
    @classmethod
    def rank(cls, Trueke=True):
        # return sorted(cls.all_cpn,key=operator.itemgetter('name'))
        Employee.all_cpn.sort(reverse=True,key=lambda x: x[0])
        print(Employee.all_cpn)
        Employee.all_cpn.sort(key=lambda x: x[0])
        print(Employee.all_cpn)
    @staticmethod
    def show():
        print('恭喜大家取得佳绩！')

# 测试
s1 = Employee('小米', '6500')
# 放入员工系统 all_Employee
s1.add_cpn()

s2 = Employee('小花',  '4800')
# 放入员工系统 all_Employee
s2.add_cpn()

s3 = Employee('小明',  '7000')
# 放入员工系统 all_Employee
s3.add_cpn()

# 统一排序:
s1.rank()



